<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <Child 
      :movies="movies"
      @send:index = "delMovies"
    ></Child>
  </div>
  <script src="./vue.js"></script>
  <script>
    const Child = {
      template: `
        <ul>
          <li 
            v-for="(movie, index) in movies"
            @click="del(index)"
          >{{movie}}</li>
        </ul>
      `,
      props: ['movies'],
      methods: {
        del (index) {
          // console.log(index)
          this.$emit('send:index', index)
        }
      }
    }

    Vue.component('Child', Child)

    const app = new Vue({
      el: '#app',
      data: {
        movies: ['电影1', '电影2', '电影3']
      },
      methods: {
        delMovies (index) {
          console.log(index)
          this.movies.splice(index, 1)
        }
      }
    })
  
  </script>
</body>
</html>